package com.xiyu.service.repository.files.certificate;

import com.xiyu.service.model.files.certificate.FilesHousingOwnershipFetcher;
import com.xiyu.service.model.office.area.OfficeAreaFetcher;
import com.xiyu.service.vo.files.housingOwnership.HousingOwnershipPageQueryInput;
import com.xiyu.service.model.files.certificate.FilesHousingOwnership;
import com.xiyu.service.model.files.certificate.FilesHousingOwnershipTable;
import org.babyfish.jimmer.spring.repository.JRepository;
import org.babyfish.jimmer.Page;

public interface FilesHousingOwnershipRepository extends JRepository<FilesHousingOwnership, Long> {
    FilesHousingOwnershipTable filesHousingOwnershipTable = FilesHousingOwnershipTable.$;

    default Page<FilesHousingOwnership> pageQuery(HousingOwnershipPageQueryInput inputVO){
        return
            sql().createQuery(filesHousingOwnershipTable)
                    .where(filesHousingOwnershipTable.user().likeIf(inputVO.getUser()))
                    .where(filesHousingOwnershipTable.fileNo().likeIf(inputVO.getFileNo()))
                    .where(filesHousingOwnershipTable.location().likeIf(inputVO.getLocation()))
                    .where(filesHousingOwnershipTable.remark().likeIf(inputVO.getRemark()))
                    .where(filesHousingOwnershipTable.area().name().likeIf(inputVO.getAreaName()))
                    .orderBy(filesHousingOwnershipTable.id().desc())
                    .select(filesHousingOwnershipTable.fetch(FilesHousingOwnershipFetcher.$.allTableFields().area(OfficeAreaFetcher.$.allTableFields())))
                    .fetchPage(inputVO.getPageNo() - 1, inputVO.getPageSize());

    }


}